In [15]:
message= "hello Python world"
print(message)
In [16]:
message= "my shoes are old"
print(message)
In [17]:
message= "my shoes are older than yours"
In [18]:
my_string='this is a single quote string'
print (my_string)
In [19]:
my_string= "this is a double quote string"
print (my_string)
In [20]:
quote= 'A coder once said, A string is as good as the author'
print quote
In [21]:
first_name='John'
print (first_name)
In [22]:
print (first_name.title())
In [23]:
print (first_name.upper())
In [24]:
print (first_name)
print (first_name.title())
print (first_name.upper())
In [25]:
last_name = 'Thompson'
full_name = first_name+ ' ' +last_name
message=full_name.title()+ ' ' + "\tWas called the worst computer programmer at the place"
In [26]:
print (message)
In [27]:
print (message)
In [28]:
print (message)
In [29]:
print (message)
In [30]:
print "Hello everyone!"
In [31]:
print "\tHello everyone!"
In [32]:
print "\nHello\n\n\n\neveryone!"
In [32]:
In [33]:
print (3+2)
In [34]:
print 3*2
In [35]:
print (3**3)
In [36]:
print (3**3*3*3)
In [37]:
#made a few errors but succeeded in de-bugging most things my self
In [38]:
%%bash
pwd
In [39]:
%%bash
cd /home
ls
In [40]:
ls
Hello John. Some good process here. Rember you can assign number values to a variable - along with what you have done with strings already. Here's an example:
In [57]:
numb = 5
highnum = 15
print 5 + 15
There are many python modules that are not loaded by default. We can tell the program what to open by using the import command. random is a module worth getting to know.
In [58]:
import random
In [60]:
randnum = random.randint(0,20)
This will give you a random number between 0 and 20
In [63]:
print randnum
You should check out lists next - they are a great way of holding a bunch of data together. You can make something a list by using [ ]. Here's we go:
In [42]:
newlist = []
print newlist
This makes a new empty list called newlist. There is nothing in it, but we can add to it with append
In [46]:
newlist.append(message)
print newlist
Lists are good because you can edit them. Another way of holding data is a tuple. These are made with ()
In [54]:
newtuple = ('hello', 'john', 'this is not a list')
In [55]:
print newtuple
In [56]:
newtuple.count('hello')
Out[56]:
Tuples can not be changed unlike lists.
In [16]:
print(40/3)
print(7**2)
print(19-5)
print("This is a long line of text that has been \nedited with the new line command. \t\nThe tab command has been used as a further editing \nexercize")
In [18]:
"""
Two edit commands can be used together
to create two seperate events on the same line
of text e.g....
"""
print("mary had a pair of shoes that did not fit her")
mskannntoowehhh
In [19]:
def addnum(mynumber):
return mynumber + 5
In [21]:
addnum(-15)
Out[21]:
In [28]:
addnum(+35)
Out[28]:
using markdown willgive auto notes.. Using heading gives pretty fonts format and compose by Simple function is def addnum(mynumber):then return mynumber (choose n+-) no multiply or division
In [31]:
print(type(3+7))
print(5*8)
print(type("Here is a written text"))
In [32]:
a = 3+5
b = a * a - a - 1
c = a * b
print(c)
In [36]:
a =3+5
b = a * a - a - 1
c = a * b
if (a>0):
print(c)
else:
print (c-a)
LISTS Remember the list begins at zero and you can change inividual values
In [37]:
a= [1, -7, 0, 0, 5, 10]
a [3]= "no number"
print a
In [38]:
a [2]= 19
print a
In [ ]: